package com.lx.pc.service.transaction.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.stereotype.Service;

import com.lx.pc.domain.entity.transaction.TransactionEntity;
import com.lx.pc.domain.vo.transaction.TransactionVo;
import com.lx.pc.mybatis.repository.transaction.TransactionRepository;
import com.lx.pc.service.AbstractService;
import com.lx.pc.service.transaction.ITransactionService;
import com.lx.pc.utils.OmsPage;

@Service("transactionService")
public class TransactionServiceImpl extends AbstractService<TransactionEntity, TransactionVo, BigInteger, TransactionRepository> implements ITransactionService{

	@Override
	public int findByTransactionCount(TransactionVo transaction) {
		return repository.findByTransactionCount(transaction);
	}

	@Override
	public OmsPage<TransactionVo> findByTransaction(TransactionVo transaction, Integer page, Integer size) {
		OmsPage<TransactionVo> pages = new OmsPage<TransactionVo>();
		pages.setTotal(repository.findByTransactionCount(transaction));
		List<TransactionEntity> list = repository.findByTransaction(transaction,page = (page - 1) * size,size);
		pages.setResult(etoV(list));
		return pages;
	}

	@Override
	public Float findByTransactionIncomeCount(TransactionVo transaction) {
		return repository.findByTransactionIncomeCount(transaction);
	}

	@Override
	public Float findByTransactionExpenditureCount(TransactionVo transaction) {
		return repository.findByTransactionExpenditureCount(transaction);
	}

}
